import { hashHistory } from 'react-router';

export const DEFAULT_TITLE = "React Test";
export const PRODUCT_SERVER_URL = "http://www.4fz3.com";
export const DEV_SERVER_URL = "http://localhost:9000";

//当前是否处于开发环境
export function isDevEnv(){
	let env = process.env;
	if(env.NODE_ENV == 'dev'){
		return true;
	}else{
		return false;
	}
}

//开发、线上环境转换url
export function urlTransmit(url){
	let env = process.env;
	if(env.NODE_ENV == 'dev'){
		return DEV_SERVER_URL + url;
	}else{
		return PRODUCT_SERVER_URL + url;
	}
}

export function cacheExists(name){
	let cacheData = sessionStorage.getItem(name);
	if(cacheData){
		return true;
	}else{
		return false;
	}
}
export function cacheClear(name){
	return sessionStorage.clear();
}
export function cacheRemove(name){
	return sessionStorage.removeItem(name);
}
export function cacheGet(name){
	return JSON.parse(sessionStorage.getItem(name));
}
export function cacheSet(name, data){
	sessionStorage.setItem(name, JSON.stringify(data));
}

export function storeRemove(name){
	return localStorage.removeItem(name);
}
export function storeGet(name){
	return JSON.parse(localStorage.getItem(name));
}
export function storeSet(name, data){
	localStorage.setItem(name, JSON.stringify(data));
}
